package com.coco.group.service.impl;

import com.coco.group.mapper.GroupOrderMapper;
import com.coco.group.pojo.TbGroupOrder;
import com.coco.group.service.GroupOrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author minicoco
 * @version 1.0
 * @date 2021/7/30 19:36
 */
@Slf4j
@Service
public class GroupOrderServiceImpl implements GroupOrderService {

    @Autowired(required = false)
    private GroupOrderMapper orderMapper;

    @Override
    public TbGroupOrder findByUserIdAndStatus(Long userId, String status) {

        return orderMapper.findByUserIdAndStatus(userId,status);
    }

    /**
     * 查询单条
     * @param id
     * @return
     */
    @Override
    public TbGroupOrder findByOrderId(String id) {

        return orderMapper.findByOrderId(id);
    }

    /**
     * 修改订单信息
     * @param groupOrder
     */
    @Override
    public void updateOrder(TbGroupOrder groupOrder) {
        orderMapper.updateOrder(groupOrder);
    }

    /**
     * 删除过期的订单
     * @param id
     */
    @Override
    public void deleteGroupOrderById(String id) {
        orderMapper.deleteGroupOrderById(id);
    }

    /**
     * 修改订单状态
     * @param tradeNo
     * @param status
     */
    @Override
    public void updateOrderStatus(String tradeNo, Integer status) {
        orderMapper.updateOrderStatus(tradeNo,status);

    }
}
